﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 花店管理系统
{
    public partial class SubmitCart : Form
    {
        private List<string> flowerNames;

        public SubmitCart(List<string> flowerNames)
        {
            InitializeComponent();
            this.flowerNames = flowerNames;
        }
        public SubmitCart()
        {
            InitializeComponent();
            
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DB.GetCn();
            string str = BuildOrderInsertSql();
            ShopCart.profit = 0;
            DB.SqlEx(str);
            //MessageBox.Show("已成功结算，欢迎下次惠顾");
            ProcessPayment();
            DB.cn.Close();
        }

        private void ProcessPayment()
        {
            geren.Zhifu zf = new geren.Zhifu();
            zf.ShowDialog();
            this.Close();
        }

        private string BuildOrderInsertSql()
        {
            string flowerNamesString = String.Join(",", flowerNames);
            string str = "insert into Torder values('" + Login.username + "','" + DateTime.Today + "','" + txtAdd.Text + "','"
                + txtCity.Text + "','" + txtState + "','" + txtZip.Text + "','"
                + txtPhone.Text + "','未审核',null," + ShopCart.profit + ",null,null,null,null,'"
                + flowerNamesString + "')";
            return str;
        }

        private void SubmitCart_Load(object sender, EventArgs e)
        {

        }
    }
}
